﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.ServiceLocation;

namespace SkeletonNET.Common.Logging
{
    /// <summary>
    /// Logging system wrapper.
    /// This class can/must be used in the application to do the logging. 
    /// Using this wrapper class will make it possible to implement any logging system you'd like.
    /// </summary>
    /// <typeparam name="Type">The type of the YPE.</typeparam>
    public static class Log<Type>
    {
        /// <summary>
        /// Get a logginhandler instance.
        /// </summary>
        /// <typeparam name="TLogHandler">The type of the log handler.</typeparam>
        /// <returns>Type of the LogHandler which you requested.</returns>
        public static TLogHandler Handler<TLogHandler>()
            where TLogHandler : LogHandler
        {
            var handler = ServiceLocator.Current.GetInstance<TLogHandler>();
            handler.CallerType = typeof(Type);
            return handler;
        }

        /// <summary>
        /// Gets or sets the current loghandler.
        /// </summary>
        /// <value>
        /// The current.
        /// </value>
        public static LogHandler Current
        {
            get { return Handler<LogHandler>(); }
        }
    }
}